<template>
  <div class="container">
    <div class="title">{{ title }}</div>
    <div class="content">
      <div
        v-for="(item, index) in list"
        :key="index"
        @click="toVideoDetail(item.id)"
      >
        <img :src="item.img" class="videoCover" />
        <h2>{{ item.title }}</h2>
      </div>
    </div>
  </div>
</template>

<script>
module.exports = {
  name: "VideoList",
  props: {
    title: {
      type: String,
      default: "",
    },
    list: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {};
  },
  methods: {
    /**
     * 跳转到视频详情页
     * @param {String} id
     */
    toVideoDetail(id) {
      window.location.href = "/videoDetail.html?id=" + id;
    },
  },
};
</script>

<style scoped>
  .container {
    max-width: 1265px;
    margin-top: 30px;
  }
  .title {
    font-size: 36px;
    letter-spacing: 18px;
  }
  .content {
    width: 100%;
    min-width: 630px;
    /* display: flex;
    flex-wrap: wrap; */
    margin-top: 20px;
    background-color: white;
    padding: 25px;
    box-sizing: border-box;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 16px;
  }
  .content div {
    max-width: 270px;
    min-width: 270px;
    min-height: 320px;
    /* flex: 1; */
    display: flex;
    flex-direction: column;
  }
  .content div:last-child {
    margin-right: 0;
  }
  .videoCover {
    width: 100%;
    height: 205px;
    border-radius: 15px;
  }
  .content h2 {
    color: rgba(16, 16, 16, 1);
    font-size: 16px;
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    white-space: normal !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 25px;
  }

  @media screen and (max-width: 1250px) {
    .content {
      grid-template-columns: repeat(3, 1fr) !important;
    }
  }
</style>